package PAT.乙.模拟;


import java.io.BufferedReader;
import java.io.InputStreamReader;


/**
 * 锤子剪刀布
 *
 * @author yang
 * @date 2021/12/21
 */
public class 锤子剪刀布 {

    public static void main(String[] args) throws Exception {

        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        String[] s = new String[]{"B","C","J"};
        // 每个选择的赢的个数
        int[] countA = new int[3];
        int[] countB = new int[3];

        int[] A = new int[3];
        int[] B = new int[3];
        while (n-- > 0) {
            String[] s1 = br.readLine().split(" ");
            String c = s1[0];
            String y = s1[1];
            int a = change(c);
            int b = change(y);
            if ((a + 1) % 3 == b) {
                A[0]++;
                B[2]++;
                countA[a]++;
            } else if (a == b) {
                A[1]++;
                B[1]++;
            } else {
                A[2]++;
                B[0]++;
                countB[b]++;
            }
        }
        System.out.println(A[0] + " " + A[1] + " " + A[2]);
        System.out.println(B[0] + " " + B[1] + " " + B[2]);

        int id1 = 0;
        int id2 = 0;
        for (int i = 0; i < 3; i++) {
            if (countA[i] > countA[id1]) id1 = i;
            if (countB[i] > countB[id2]) id2 = i;
        }
        System.out.println(s[id1] + " "+s[id2]);

    }
    public static int change(String c) {
        if (c.equals("B")) return 0;
        if (c.equals("C")) return 1;
        if (c.equals("J")) return 2;
        return 0;
    }

}
